'''
Created on Mar 7, 2016

@author: JimmyMo
'''
from writter.perfsynwritter import Writter
import os
class Writter4File(Writter):
    def _parse_options(self):
#         Writter._parse_options(self)
        self.file_path = "/tmp/perf_generator.log"
        self.mode = "a+"
    def flush_db(self):
        if os.path.exists(self.file_path):
            os.remove(self.file_path)
        
    def _write(self):
        logs4all_devices = self.event_buffer_list
        with open(self.file_path, self.mode) as f:
            for i, doc in enumerate(logs4all_devices):
                f.write(str(doc) + '\n')
                #print("writting device #%d" % i)
#                 for p in logs4device:
#                     f.write(str(p) + '\n')